package cn.com.vastbase.jpa.dao;

import cn.com.vastbase.jpa.dataobject.UserDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Optional;

@Repository
public interface UserRepository extends JpaRepository<UserDO, Integer> {

    @Query(value = "select u.* from users u where  IF(?1 is null, true, u.username LIKE CONCAT('%',ifnull( ?1 , 'null' ),'%'))", nativeQuery = true)
    Optional<List<UserDO>> findByUsername(String username);
}
